<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="org.apache.shiro.web.filter.authc.FormAuthenticationFilter" %>
<%@ page import="org.apache.shiro.authc.LockedAccountException " %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="sitemesh" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<script type="text/javascript">
    $(function () {
        $("#username").focus();
    });

    function openDialog4PC(){
       // alert(111);
    }
</script>

<div class="login">
    <div class="ui-widget"></div>



    <form id="loginform" action="${ctx}/" method="post">
        <fieldset style="display: block;" id="signin_menu">
            <p>
                <label for="username">登陆名<span class="red">*</span></label>
                <input name="username" id="username" value="${username}" class="text" title="请输入登录用户名" tabindex="1"
                       style="width: 200px;">
            </p>

            <p>
                <label for="password">密&nbsp;&nbsp;码<span class="red">*</span></label>
                <input type="password" name="password" tabindex="2" id="password" class="text"
                       title="请输入密码" style="width: 200px;">
            </p>
            <%
                String error = (String) request.getAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME);
                if (error != null) {
            %>
            <div class="alert alert-error controls input-large" style="color:red;margin-left: 60px;">

                <%
                    if (error.contains("DisabledAccountException")) {
                        out.print("用户已被屏蔽,请登录其他用户.");
                    } else if(error.contains("LockedAccountException")) {
                        out.print("用户已被锁,请联系系统管理人员.");
                    } else if(error.contains("ExpiredCredentialsException")) {
                        out.print("账户已过期，请重置密码.");
                    } else if(error.contains("ExcessiveAttemptsException")) {
                        out.print("您已经尝试登录失败过多，账户被锁，请联系系统管理人员.");
                    } else {
                        out.print("登录失败，请重试.");
                    }
                %>
            </div>
            <%
                }
            %>

                <input id="signin_submit" value="登陆"
                       tabindex="4" type="submit"
                       class="btn_blue"
                       role="button" aria-disabled="false">

        </fieldset>
    </form>
</div>
<div class="clr"></div>
<shiro:authenticated>
	<script>
		$("#loginform").attr("action", "${ctx}/home?random="+new Date());
		$("#loginform").submit();
	</script>
</shiro:authenticated>